/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Cuchu
 */
@Stateless
public class RecensioneEsternaFacade extends AbstractFacade<RecensioneEsterna> implements RecensioneEsternaFacadeLocal {
    
    @PersistenceContext(unitName = "webApplication-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public RecensioneEsternaFacade() {
        super(RecensioneEsterna.class);
    }

    @Override
    public boolean esistente(RecensioneEsterna r) {
        return ! (em.createQuery("select url from RecensioneEsterna where autore='"+r.getUrl()+"'").getResultList().isEmpty());
    }
    
    @Override
    public RecensioneEsterna getRecensioneEsterna(Long id) {
        return (RecensioneEsterna)(em.createQuery("select * from RecensioneEsterna where UPPER(id) ='" + id + "'").getSingleResult());    }
}
